package com.bdqn.utli;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;

/**
 * @author 忍
 * @title: CookieUtil
 * @projectName Teaching
 * @description: TODO
 * @date 2019/4/289:32
 */
public class CookieUtil {
    public static void addCoookie(HttpServletResponse response,String name,Object value,int maxAge){
        if (value!=null){
            Cookie cookie = new Cookie(name, value.toString());
            cookie.setPath("/");
            if (maxAge > 0) {
                cookie.setMaxAge(maxAge);
            }
            response.addCookie(cookie);
        }
    }
}
